//vuex 模块化开发
import {resCategoryList, resFloorList} from "@/api";
import {resBannerList} from "@/api";

const state = {
    categoryList: [],
    bannerList: [],
    floorList:[],
}
const actions = {
    async categoryList(context) {
        const result = await resCategoryList();
        // console.log(result)查看从后台接收到的数据
        //当code==200，则向mutations存储数据
        if (result.code == 200) {
            context.commit('CATEGORYLIST', result.data)
        }
    },
    async bannerList(context){
        const result =await resBannerList();
        if(result.code==200){
            context.commit('BANNERLIST',result.data)
        }
    },
    async floorList(context){
        const result =await resFloorList();
        if(result.code==200){
            context.commit('FLOORLIST',result.data)
        }
    }
}
const mutations = {
    CATEGORYLIST(state, value) {
        state.categoryList = value;
    },
    BANNERLIST(state,value){
        state.bannerList=value;
    },
    FLOORLIST(state,value){
        state.floorList=value;
    }
}
const getters = {}
export default {
    state,
    actions,
    mutations,
    getters
}